import type { AdColumn } from '@/components/AdVxeTable';

import { getDeviceStatusEnumSchema } from '@/enums/iot/deviceStatusEnum';
import { useI18n } from '@/hooks/web/useI18n';

const deviceStatusEnumSchema = getDeviceStatusEnumSchema();

const { t } = useI18n();

export const columns: AdColumn[] = [
  {
    title: t('entity.idTitle'),
    field: 'Id',
    width: 150,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('iot.route.state.device.deviceIdText'),
    field: 'DeviceId',
    width: 150,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('iot.route.state.device.deviceNameText'),
    field: 'DeviceName',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'Device.Name',
    dataType: 'string',
  },
  {
    title: t('iot.route.state.device.statusText'),
    field: 'Status',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'enum',
    enumData: deviceStatusEnumSchema,
  },
  {
    title: t('iot.route.state.device.createdTimeText'),
    field: 'CreatedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
  {
    title: t('iot.route.state.device.endedTimeText'),
    field: 'EndedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
  {
    title: t('iot.route.state.device.elapsedText'),
    field: 'Elapsed',
    // width: 120,
    minWidth: 120,
    formVisible: true,
    formEditable: false,
    filterable: false,
    dataType: 'number',
  },
  {
    title: t('iot.route.state.device.enabledText'),
    field: 'Enabled',
    width: 90,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'boolean',
  },
  {
    title: t('iot.route.state.device.connectedText'),
    field: 'Connected',
    width: 90,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'boolean',
  },
];
